<?php
/**
 * appRain v 0.1.x
 *
 * LICENSE
 *
 * This source file is subject to the MIT license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.opensource.org/licenses/mit-license.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@apprain.com so we can send you a copy immediately.
 *
 * @copyright  Copyright (c) 2010 appRain, Inc. (http://www.apprain.com)
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 *
 * HELP
 * 
 * Official Website 
 * http://www.apprain.com/
 *
 * Download Link
 * http://www.apprain.com/download
 *
 * Documents Link
 * http ://www.apprain.com/documents
 */

class Development_AppCommon extends Development_AddonFxs
{
    protected function is_selected( $s, $n)
    {
        return ( $s == $n ) ? 'class="selected"' : "";
    }

    protected function getsubCategory($id = NULL)
    {
       $subCategory = App::Model('Category')->findAll("parent_id={$id} ORDER BY generic ASC");
       return $subCategory['data'];
    }
    
    protected function relatedPostLinks($cid = NULL)
    {
        $html = App::Helper('Html');
        $relatedpostarr = App::InformationSet('manual-post')->findAll("1 ORDER BY generic ASC",Array(Array("category"=>"{$cid}")));
        $markup = $html->getTag('ul',Array('class'=>'links'));
        foreach($relatedpostarr['data'] as $post)
        {
            $markup .= $html->getTag('li',$html->linkTag($this->baseurl("/manual/p/{$post['id']}/" . App::Helper('Utility')->text2normalize($post['title'])),$post['title']));
        }
        $markup .= $html->getTag('/ul');
        
        return $markup;
    }
    
    protected function pageNameToMetaInfo($pageName)
    {
        $pageData = App::PageManager()->getData($pageName);
        if(!empty($pageData))
        {
            $this->page_title = $pageData['page_title'];
            $this->page_meta_keyowrds = $pageData['meta_keywords'];
            $this->page_meta_desc = $pageData['meta_description'];
        }
        return $pageData;
    }
    
    protected function isCatHasPost($cid, $IS_type)
    {
        $dataArr = App::InformationSet($IS_type)->findByCategory($cid);
        return !empty($dataArr);
    }
}
